package com.yuexunit.operationman.nbsy.module.OperationBeforeAndAfter.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


import com.yuexunit.operationman.nbsy.R;
import com.yuexunit.operationman.nbsy.config.AppConfig;

import org.kymjs.kjframe.ui.KJFragment;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by chenss on 2017/11/14 0014.
 */

public class Frag_Operation_BeforVisit extends KJFragment {
    @Bind(R.id.bv_01)
    TextView bv01;
    @Bind(R.id.bv_02)
    TextView bv02;
    @Bind(R.id.bv_03)
    TextView bv03;
    @Bind(R.id.bv_04)
    TextView bv04;
    @Bind(R.id.bv_05)
    TextView bv05;
    @Bind(R.id.bv_06)
    TextView bv06;
    @Bind(R.id.bv_07)
    TextView bv07;
    @Bind(R.id.bv_08)
    TextView bv08;
    @Bind(R.id.bv_09)
    TextView bv09;
    @Bind(R.id.bv_10)
    TextView bv10;
    @Bind(R.id.bv_11)
    TextView bv11;
    @Bind(R.id.bv_12)
    TextView bv12;
    @Bind(R.id.bv_13)
    TextView bv13;
    @Bind(R.id.bv_14)
    TextView bv14;
    @Bind(R.id.bv_15)
    TextView bv15;
    @Bind(R.id.bv_16)
    TextView bv16;
    @Bind(R.id.bv_17)
    TextView bv17;
    @Bind(R.id.bv_18)
    TextView bv18;
    @Bind(R.id.bv_19)
    TextView bv19;
    protected View mMainView;

    @Override
    protected View inflaterView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
        mMainView = inflater.inflate(R.layout.frag_operation_beforvisit, container, false);
        ButterKnife.bind(this, mMainView);
        return mMainView;
    }

    @Override
    protected void initData() {
        bv01.setText(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getTemperature()+"℃");
        bv02.setText(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getPulse()+"次/分");
        bv03.setText(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getBp()+"mmHg");
        bv04.setText(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getEeg());
        bv05.setText(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getRedCell());
        bv06.setText(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getWhiteCell());
        bv07.setText(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getHemoglobin());
        bv08.setText(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getBloodCell());
        bv09.setText(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getBloodType());
        bv10.setText(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getLiver());
        bv11.setText(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getOtherDisease());
        if(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getSkinTest().length()>0)
        {
            if(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getSkinTest().equals("0"))
            {
                bv12.setText("青");
            }
            else if(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getSkinTest().equals("1"))
            {
                bv12.setText("普");
            }
        }
        bv13.setText(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getOtherAcroaesthesia());
        if(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getSkin().equals("0"))
        {
            bv14.setText("合格");
        }
        else  if(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getSkin().equals("1"))
        {
            bv14.setText("欠佳");
        }
        else  if(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getSkin().equals("2"))
        {
            bv14.setText("不合格");
        }
        if(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getFasting().equals("0"))
        {
            bv15.setText("是");
        }
        if(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getBladderPrepare().equals("0"))
        {
            bv16.setText("是");
        }
        if(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getPremedicate().equals("0"))
        {
            bv17.setText("是");
        }
        if(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getPsychology().length()>0) {
            String[] arrays = AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getPsychology().split(";", -1);
            String[] arrayNames = getResources().getStringArray(R.array.beforeandafter_01);
            String content = "";
            if(arrays[0].equals("1"))
            {
                content+=arrayNames[0];
            }
            if(arrays[1].equals("1"))
            {
                if (content.length() > 0) {
                    content += "\n";
                    content += arrayNames[1];
                }
                else {
                    content += arrayNames[1];
                }
            }
            if(arrays[2].equals("1"))
            {
                if (content.length() > 0) {
                    content += "\n";
                    content += arrayNames[2];
                }
                else {
                    content += arrayNames[2];
                }
            }
            if(arrays[3].equals("1"))
            {
                if (content.length() > 0) {
                    content += "\n";
                    content += arrayNames[3];
                }
                else {
                    content += arrayNames[3];
                }
            }
            if(arrays[4].equals("1"))
            {
                if (content.length() > 0) {
                    content += "\n";
                    content += arrayNames[4];
                }
                else {
                    content += arrayNames[4];
                }
            }
            if(arrays[5].equals("1"))
            {
                if (content.length() > 0) {
                    content += "\n";
                    content += arrayNames[5];
                }
                else {
                    content += arrayNames[5];
                }
            }
            bv18.setText(content);
        }

        if(AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getHealthEducation().length()>0) {
            String[] arrays = AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getHealthEducation().split(";", -1);
            String[] arrayNames = getResources().getStringArray(R.array.beforeandafter_02);
            String content = "";
            if(arrays[0].equals("1"))
            {
                content+=arrayNames[0];
            }
            if(arrays[1].equals("1"))
            {
                if (content.length() > 0) {
                    content += "\n";
                    content += arrayNames[1];
                }
                else {
                    content += arrayNames[1];
                }
            }
            if(arrays[2].equals("1"))
            {
                if (content.length() > 0) {
                    content += "\n";
                    content += arrayNames[2];
                }
                else {
                    content += arrayNames[2];
                }
            }
            if(arrays[3].equals("1"))
            {
                if (content.length() > 0) {
                    content += "\n";
                    content += arrayNames[3];
                }
                else {
                    content += arrayNames[3];
                }
            }
            if(arrays[4].equals("1"))
            {
                if (content.length() > 0) {
                    content += "\n";
                    content += arrayNames[4];
                }
                else {
                    content += arrayNames[4];
                }
            }
            if(arrays[5].equals("1"))
            {
                if (content.length() > 0) {
                    content += "\n";
                    content += arrayNames[5];
                }
                else {
                    content += arrayNames[5];
                }
            }
            if(arrays[6].equals("1"))
            {
                if (content.length() > 0) {
                    content += "\n";
                    content += "其他:"+AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getOtherHealthEducation();
                }
                else {
                    content += "其他:"+AppConfig.BEFOREANDAFTERBEAN.getObject().getBeforeNursing().getOtherHealthEducation();
                }
            }
            bv19.setText(content);
        }
    }
}
